home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / a-strbou.ads < prev    next >
Text File  |  1994-05-19  |  11KB  |  346 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                  A D A . S T R I N G S . B O U N D E D                   --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.4 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25.  
  26. with Ada.Strings.Maps;
  27.  
  28. package Ada.Strings.Bounded is
  29.  
  30.    pragma Pure;
  31.  
  32.    Blank : constant Character := ' ';
  33.  
  34.    generic
  35.       Max : Positive;    -- Maximum length of a Bounded_String
  36.  
  37.    package Generic_Bounded_Length is
  38.  
  39.       Max_Length : constant Positive := Max;
  40.  
  41.       type Bounded_String is private;
  42.  
  43.       Null_Bounded_String : constant Bounded_String;
  44.  
  45.       subtype Length_Range is Natural range 0 .. Max_Length;
  46.  
  47.       ------------
  48.       -- Length --
  49.       ------------
  50.  
  51.       function Length (Source : in Bounded_String) return Length_Range;
  52.  
  53.       -----------------------------------------------------
  54.       -- Conversion, Catenation, and Selection Functions --
  55.       -----------------------------------------------------
  56.  
  57.       function To_Bounded_String
  58.         (Source : in String;
  59.          Drop   : in Truncation := Error)
  60.          return   Bounded_String;
  61.  
  62.       function To_String (Source : in Bounded_String) return String;
  63.  
  64.  
  65.       function Append
  66.         (Left, Right : in Bounded_String;
  67.          Drop        : in Truncation  := Error)
  68.          return        Bounded_String;
  69.  
  70.       function Append
  71.         (Left  : in Bounded_String;
  72.          Right : in String;
  73.          Drop  : in Truncation := Error)
  74.          return  Bounded_String;
  75.  
  76.       function Append
  77.         (Left  : in String;
  78.          Right : in Bounded_String;
  79.          Drop  : in Truncation := Error)
  80.          return  Bounded_String;
  81.  
  82.       function Append
  83.         (Left  : in Bounded_String;
  84.          Right : in Character;
  85.          Drop  : in Truncation := Error)
  86.          return  Bounded_String;
  87.  
  88.       function Append
  89.         (Left  : in Character;
  90.          Right : in Bounded_String;
  91.          Drop  : in Truncation := Error)
  92.          return  Bounded_String;
  93.  
  94.       function "&" (Left, Right : in Bounded_String)
  95.          return Bounded_String;
  96.  
  97.       function "&" (Left : in Bounded_String; Right : in String)
  98.          return Bounded_String;
  99.  
  100.       function "&" (Left : in String; Right : in Bounded_String)
  101.          return Bounded_String;
  102.  
  103.       function "&" (Left : in Bounded_String; Right : in Character)
  104.          return Bounded_String;
  105.  
  106.       function "&" (Left : in Character; Right : in Bounded_String)
  107.          return Bounded_String;
  108.  
  109.       function Element
  110.         (Source : in Bounded_String;
  111.          Index  : in Positive)
  112.          return   Character;
  113.  
  114.       procedure Replace_Element
  115.         (Source : in out Bounded_String;
  116.          Index  : in Positive;
  117.          By     : in Character);
  118.  
  119.       function Slice
  120.         (Source : in Bounded_String;
  121.          Low    : in Positive;
  122.          High   : in Natural)
  123.          return   String;
  124.  
  125.       function "="  (Left, Right : in Bounded_String) return Boolean;
  126.  
  127.       function "<"  (Left, Right : in Bounded_String) return Boolean;
  128.  
  129.       function "<=" (Left, Right : in Bounded_String) return Boolean;
  130.  
  131.       function ">"  (Left, Right : in Bounded_String) return Boolean;
  132.  
  133.       function ">=" (Left, Right : in Bounded_String) return Boolean;
  134.  
  135.       ----------------------
  136.       -- Search Functions --
  137.       ----------------------
  138.  
  139.       function Index
  140.         (Source   : in Bounded_String;
  141.          Pattern  : in String;
  142.          Going    : in Direction := Forward;
  143.          Mapping  : in Maps.Character_Mapping := Maps.Identity)
  144.          return     Natural;
  145.  
  146.       function Index
  147.         (Source : in Bounded_String;
  148.          Set    : in Maps.Character_Set;
  149.          Test   : in Membership := Inside;
  150.          Going  : in Direction  := Forward) return Natural;
  151.  
  152.       function Index_Non_Blank
  153.         (Source : in Bounded_String;
  154.          Going  : in Direction := Forward)
  155.          return   Natural;
  156.  
  157.       function Count
  158.         (Source   : in Bounded_String;
  159.          Pattern  : in String;
  160.          Mapping  : in Maps.Character_Mapping := Maps.Identity)
  161.          return     Natural;
  162.  
  163.       function Count
  164.         (Source   : in Bounded_String;
  165.          Set      : in Maps.Character_Set)
  166.          return     Natural;
  167.  
  168.       procedure Find_Token
  169.         (Source : in Bounded_String;
  170.          Set    : in Maps.Character_Set;
  171.          Test   : in Membership;
  172.          First  : out Positive;
  173.          Last   : out Natural);
  174.  
  175.       ------------------------------------
  176.       -- String Translation Subprograms --
  177.       ------------------------------------
  178.  
  179.       function Translate
  180.         (Source   : in Bounded_String;
  181.          Mapping  : in Maps.Character_Mapping)
  182.          return     Bounded_String;
  183.  
  184.       procedure Translate
  185.         (Source   : in out Bounded_String;
  186.          Mapping  : in Maps.Character_Mapping);
  187.  
  188.       ---------------------------------------
  189.       -- String Transformation Subprograms --
  190.       ---------------------------------------
  191.  
  192.       function Replace_Slice
  193.         (Source   : in Bounded_String;
  194.          Low      : in Positive;
  195.          High     : in Natural;
  196.          By       : in String;
  197.          Drop     : in Truncation := Error)
  198.          return     Bounded_String;
  199.  
  200.       procedure Replace_Slice
  201.         (Source   : in out Bounded_String;
  202.          Low      : in Positive;
  203.          High     : in Natural;
  204.          By       : in String;
  205.          Drop     : in Truncation := Error);
  206.  
  207.       function Insert
  208.         (Source   : in Bounded_String;
  209.          Before   : in Positive;
  210.          New_Item : in String;
  211.          Drop     : in Truncation := Error)
  212.          return     Bounded_String;
  213.  
  214.       procedure Insert
  215.         (Source   : in out Bounded_String;
  216.          Before   : in Positive;
  217.          New_Item : in String;
  218.          Drop     : in Truncation := Error);
  219.  
  220.       function Overwrite
  221.         (Source    : in Bounded_String;
  222.          Position  : in Positive;
  223.          New_Item  : in String;
  224.          Drop      : in Truncation := Error)
  225.          return      Bounded_String;
  226.  
  227.       procedure Overwrite
  228.         (Source    : in out Bounded_String;
  229.          Position  : in Positive;
  230.          New_Item  : in String;
  231.          Drop      : in Truncation := Error);
  232.  
  233.       function Delete
  234.         (Source  : in Bounded_String;
  235.          From    : in Positive;
  236.          Through : in Natural)
  237.          return    Bounded_String;
  238.  
  239.       procedure Delete
  240.         (Source  : in out Bounded_String;
  241.          From    : in Positive;
  242.          Through : in Natural);
  243.  
  244.       ---------------------------------
  245.       -- String Selector Subprograms --
  246.       ---------------------------------
  247.  
  248.       function